package com.gxa.modules.service.zxy.impl;

import com.gxa.common.constant.Constants;
import com.gxa.common.vo.R2;
import com.gxa.common.vo.R3;
import com.gxa.modules.mapper.zxy.SYMapper;
import com.gxa.modules.service.zxy.SYService;
import com.gxa.modules.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Author: zxy
 * Date: 2021/12/29 19:17
 * Description:
 * Version: V1.0
 */
@Service
public class SYServiceImpl implements SYService{
    @Autowired(required = false)
    private SYMapper syMapper;

    @Override
    public R3 queryData() {
        String date = DateUtils.getCurrentTime("yyyy-MM-dd");
        System.out.println("===================");
        System.out.println(date);
        Integer todayShop = syMapper.countTodayShop(date);
        Integer auditShop = syMapper.countAuditShop();
        Integer totalShop = syMapper.countTotalShop();
        Integer todayUser = syMapper.countTodayUser(date);
        Integer auditUser = syMapper.countAuditUser();
        Integer totalUser = syMapper.countTotalUser();
        int array [] = {todayShop,auditShop,totalShop,todayUser,auditUser,totalUser};
        //查询套餐数据
        List<String> list = syMapper.queryPac();
        List<Map> taoChan = new ArrayList<>();
        System.out.println(list);

        for (String name:list) {
            Integer pacNum = syMapper.queryPacNum(name);
            Map map = new HashMap();
            map.put("value",pacNum);
            map.put("name",name);
            taoChan.add(map);
        }
        //查询套餐数量
        Integer totalPac = syMapper.countTotalPac();
        Integer tryPac = syMapper.countTryPac();
        int tc[] = {totalPac,tryPac};
        //销量排行榜
        List<Map> map1 = syMapper.queryTrade();
        System.out.println(map1);
        //新增店铺
        List<Map> map2 = syMapper.queryNewShop(date);
        System.out.println("*********************************");
        System.out.println(map2);
        R3 r = new R3();
        r.setMsg("success");
        r.setCode(Constants.SUCCESS);
        r.setData(array);
        r.setData2(taoChan);
        r.setData3(tc);
        r.setData4(map1);
        r.setData5(map2);
        return r;
    }
}
